/**
 * 
 */
package com.sys.console.monitor;

import java.util.Date;
import java.util.concurrent.ExecutorService;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;

import com.sys.console.mapper.SysUserMonitorLogsMapper;
import com.sys.console.pojo.SysUserMonitorLogs;
import com.sys.object.common.context.ServiceInitContainer;
import com.sys.object.common.utils.IpUtils;
import com.sys.object.common.utils.JsonUtil;

/**
 * @author JDYG-001
 *
 */
@Component
public class MonitorLogs {

	 public static void monitorSaveLogs(final Integer uid,final int montype,final Object bean,final HttpServletRequest request){
		 ExecutorService exec = (ExecutorService) ServiceInitContainer.getBean("executorService");
		 exec.execute((new Thread(new Runnable() {
			@Override
			public void run() {
				//if(uid!=null&&uid>0){
					SysUserMonitorLogsMapper mapper = (SysUserMonitorLogsMapper) ServiceInitContainer.getBean("userMonitorLogsMapper");
					String url = request.getRequestURI();
					//System.out.println(mapper+"=====MonitorLogs=============monitorSaveLogs======="+uid+"====");
					SysUserMonitorLogs mon = new SysUserMonitorLogs();
					mon.setUid(uid);
					mon.setMontime(new Date());
					mon.setMontype(montype);
					mon.setMontext(JsonUtil.beanToJson(bean));
					mon.setMonip(IpUtils.getIpAddr(request));
					mon.setMonaction(url);
					mon.setMethods(request.getMethod());
					mapper.insert(mon);
				//}
			}
		})));
	 }
	 
	 public static void filterSaveLogs(final Integer uid,final int montype,final Object bean,final HttpServletRequest request){
		 ExecutorService exec = (ExecutorService) ServiceInitContainer.getBean("executorService");
		 exec.execute((new Thread(new Runnable() {
			@Override
			public void run() {
				//if(uid!=null&&uid>0){
					SysUserMonitorLogsMapper mapper = (SysUserMonitorLogsMapper) ServiceInitContainer.getBean("userMonitorLogsMapper");
					String url = request.getRequestURI();
					//System.out.println(mapper+"=====filterSaveLogs=============filterSaveLogss======="+uid+"====");
					SysUserMonitorLogs mon = new SysUserMonitorLogs();
					mon.setUid(uid);
					mon.setMontime(new Date());
					mon.setMontype(montype);
					mon.setMontext(JsonUtil.beanToJson(bean));
					mon.setMonip(IpUtils.getIpAddr(request));
					mon.setMonaction(url);
					mon.setMethods(request.getMethod());
					//System.out.println(mapper+"=====filterSaveLogs=============filterSaveLogss======="+uid+"===="+mon);
					mapper.insertFilter(mon);
				//}
			}
		})));
	 }
	 
	 public static void main(String[] args){
		 System.out.println(18000/21.5/7.5);
		 System.out.println((67.5+55+7+16));
	 }
}
